package com.dnw.shyfunny;

import android.content.Intent;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.dnw.adapter.NavAdapter;
import com.dnw.base.BaseActivity;
import com.dnw.base.BasePresenter;
import com.dnw.util.SharedPreferencesMgr;
import com.dnw.util.UIUtils;

import java.util.ArrayList;
import java.util.List;

import butterknife.Bind;
import flyn.Eyes;
import me.relex.circleindicator.CircleIndicator;

/**
 * Created by yangyu on 2017/11/16.
 * 关于页面
 */

public class NavActivity extends BaseActivity {

    private List<View> lsview=new ArrayList<View>();
    private NavAdapter adapter;
    @Bind(R.id.vp_wellcome)
     ViewPager vp_wellcome;
    @Bind(R.id.bt_in)
     TextView bt_in;
    @Override
    protected int provideContentViewId() {
        return R.layout.nav_act;
    }

    @Override
    public void initView() {
        Eyes.setStatusBarColor(this, UIUtils.getColor(R.color.a));
    }

    @Override
    public void initData() {

        vp_wellcome.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {

            @Override
            public void onPageSelected(int arg0) {
                if(arg0==lsview.size()-1){
                    bt_in.setVisibility(View.VISIBLE);
                }else{
                    bt_in.setVisibility(View.GONE);
                }

            }

            @Override
            public void onPageScrolled(int arg0, float arg1, int arg2) {
                // TODO Auto-generated method stub

            }

            @Override
            public void onPageScrollStateChanged(int arg0) {
                // TODO Auto-generated method stub

            }
        });

        ImageView view1=new ImageView(this);
        view1.setBackgroundResource(R.drawable.welcome);
        ImageView view2=new ImageView(this);
        view2.setBackgroundResource(R.drawable.nav_2);
        ImageView view3=new ImageView(this);
        view3.setBackgroundResource(R.drawable.nav_3);
        ImageView view4=new ImageView(this);
        view4.setBackgroundResource(R.drawable.nav_4);
        ImageView view5=new ImageView(this);
        view5.setBackgroundResource(R.drawable.nav_5);
        lsview.add(view1);
        lsview.add(view2);
        lsview.add(view3);
        lsview.add(view4);
        lsview.add(view5);
        adapter = new NavAdapter(lsview, this);
        vp_wellcome.setAdapter(adapter);
        bt_in.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                SharedPreferencesMgr.setBoolean("isFirstCome", true);
                startActivity(new Intent(NavActivity.this, MainActivity.class));
                finish();
            }
        });

        CircleIndicator indicator = (CircleIndicator) findViewById(R.id.indicator);
        indicator.setViewPager(vp_wellcome);
    }

    @Override
    protected BasePresenter createPresenter() {
        return null;
    }

}
